package com.spark;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Objects;


/**
 * 启动类
 * @author LYCHEE
 */
@Slf4j
@SpringBootApplication
public class SparkBootstrapApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(SparkBootstrapApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = Objects.requireNonNull(env.getProperty("server.servlet.context-path")).trim();
        log.info("\n----------------------------------------------------------" +
                "\n\tApplication 【Spark-Admin】 系统启动成功! Access URLs:" +
                "\n\tLocal: \t\thttp://localhost:{}{}/" +
                "\n\tExternal: \thttp://{}:{}{}/" +
                "\n\t----------------------------------------------------------", port, path, ip, port, path);
    }

}
